//
//  UIBarButtonItem+Extensions.swift
//  status
//
//  Created by 彳亍 on 2017/3/22.
//  Copyright © 2017年 彳亍. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    /// 便利构造器
    ///
    /// - Parameters:
    ///   - tilte: 标题
    ///   - titleColor: 标题颜色
    ///   - fontSize: 标题字体
    ///   - image: 配图
    ///   - target: 监听者
    ///   - action: 监听方法
    convenience init(tilte:String,titleColor:UIColor = UIColor.orange, fontSize:CGFloat = 15, image:UIImage? = nil,target:Any?,action:Selector) {
        let button = UIButton(type: UIButtonType.custom)
        button.setTitle(tilte, for: UIControlState.normal)
        button.titleLabel?.font = UIFont.systemFont(ofSize: fontSize)
        button.setTitleColor(titleColor, for: UIControlState.normal)
        button.setImage(image, for: UIControlState.normal)
        button.sizeToFit()
        button.addTarget(target, action: action, for: UIControlEvents.touchUpInside)
        self.init(customView:button)
    }

}
